package com.jinzecloud.reportapproval.controller;

import com.jinzecloud.reportapproval.bean.Cover;
import com.jinzecloud.reportapproval.bean.Product;
import com.jinzecloud.reportapproval.dto.Param;
import com.jinzecloud.reportapproval.service.CoverService;
import com.jinzecloud.reportapproval.service.ProductService;
import com.jinzecloud.reportapproval.utils.PageUtils;
import com.jinzecloud.reportapproval.utils.R;
import com.jinzecloud.reportapproval.vo.ProductInfoVos;
import com.jinzecloud.reportapproval.vo.ReportVos;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

@RestController
@RequestMapping("reportApproval/cover")
public class CoverController {
    @Autowired
    private CoverService coverService;

    /**
     * 列表
     */
    @RequestMapping(value = "/list",method = RequestMethod.POST)
    @ApiOperation(value = "产品表列表",notes = "产品表列表")
    //@RequiresPermissions("reportApproval:product:list")
    public R list(@RequestBody Param param){
        PageUtils page = coverService.queryPage(param);

        return R.ok().put("page", page);
    }

    /**
     * 信息
     */
    @RequestMapping(value = "/info/{prId}",method = RequestMethod.POST)
    @ApiOperation(value = "产品表信息",notes = "产品表信息")
    //@RequiresPermissions("reportApproval:product:info")
    public R info(@PathVariable("prId") Integer prId){
        Cover cover = coverService.getById(prId);

        return R.ok().put("cover", cover);
    }

    @RequestMapping(value = "/info/{id}",method = RequestMethod.POST)
    @ApiOperation(value = "根据id查询检验报告接口",notes = "产品表信息")
    //@RequiresPermissions("reportApproval:product:info")
    public R getreport(@PathVariable("id") Integer id){
        Cover cover = coverService.getById(id);

        return R.ok().put("cover", cover);
    }

    /**
     * 保存
     */
    @RequestMapping(value = "/save",method = RequestMethod.POST)
    @ApiOperation(value = "产品表保存",notes = "产品表保存")
    //@RequiresPermissions("reportApproval:product:save")
    public R save(@RequestBody Cover cover){
        coverService.save(cover);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/update",method = RequestMethod.POST)
    @ApiOperation(value = "产品表修改",notes = "产品表修改")
    //@RequiresPermissions("reportApproval:product:update")
    public R update(@RequestBody Cover cover){
        coverService.updateById(cover);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping(value = "/delete",method = RequestMethod.POST)
    @ApiOperation(value = "产品表删除",notes = "产品表删除")
    //@RequiresPermissions("reportApproval:product:delete")
    public R delete(@RequestBody Integer[] prIds){
        coverService.removeByIds(Arrays.asList(prIds));

        return R.ok();
    }

}
